/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jTaskJPanel.java
 *
 * Created on 2008-12-23, 15:56:01
 */

package org.bugeden.netdisk.ui;

import org.bugeden.netdisk.user.jTask;
import org.bugeden.netdisk.utils.UIView;

import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import javax.swing.ButtonGroup;

/**
 *
 * @author bug-eden
 */
public class jTaskJPanel extends javax.swing.JPanel {

    /** Creates new form jTaskJPanel */
    public jTaskJPanel() {
        initComponents();
        ButtonGroup butGroup = new ButtonGroup();
        butGroup.add(this.send);
        butGroup.add(upload);
        butGroup.add(downLoad);
    }

  

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        upload = new javax.swing.JRadioButton();
        downLoad = new javax.swing.JRadioButton();
        send = new javax.swing.JRadioButton();
        jLabel7 = new javax.swing.JLabel();
        bulidTime = new javax.swing.JTextField();
        localFilename = new javax.swing.JTextField();
        remoteFilename = new javax.swing.JTextField();
        sourceMailBox = new javax.swing.JTextField();
        aimMailBox = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();

        jLabel1.setText(UIView.UIName("view.panel.task.file.local"));

        jLabel2.setText(UIView.UIName("view.panel.task.file.remote"));

        jLabel3.setText(UIView.UIName("view.panel.task.mailbox.source"));

        jLabel4.setText(UIView.UIName("view.panel.task.mailbox.target"));

        jLabel6.setText(UIView.UIName("view.panel.task.type"));

        upload.setText(UIView.UIName("view.panel.task.upload"));

        downLoad.setText(UIView.UIName("view.panel.task.download"));

        send.setText(UIView.UIName("view.panel.task.send"));

        jLabel7.setText(UIView.UIName("view.panel.task.buildtime"));

        jButton1.setText(UIView.UIName("view.panel.task.view"));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(18, 18, 18)
                        .addComponent(upload)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(downLoad)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(send))
                    .addComponent(jLabel7)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addGap(14, 14, 14)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(remoteFilename)
                            .addComponent(aimMailBox, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
                            .addComponent(localFilename, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(bulidTime, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
                            .addComponent(sourceMailBox, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1)))
                .addContainerGap(22, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(upload)
                    .addComponent(downLoad)
                    .addComponent(send))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(bulidTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(localFilename, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(remoteFilename, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(sourceMailBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(aimMailBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addContainerGap(49, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField aimMailBox;
    private javax.swing.JTextField bulidTime;
    private javax.swing.JRadioButton downLoad;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JTextField localFilename;
    private javax.swing.JTextField remoteFilename;
    private javax.swing.JRadioButton send;
    private javax.swing.JTextField sourceMailBox;
    private javax.swing.JRadioButton upload;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the aimMailBox
     */
    public String getAimMailBox() {
        return aimMailBox.getText();
    }

    /**
     * @param aimMailBox the aimMailBox to set
     */
    public void setAimMailBox(String aimMailBox) {
        this.aimMailBox.setText(aimMailBox);
    }

    /**
     * @return the bulidTime
     */
    public Date getBulidTime() throws ParseException {

        DateFormat d = new java.text.SimpleDateFormat();
        return d.parse(bulidTime.getText());
    }

    /**
     * @param bulidTime the bulidTime to set
     */
    public void setBulidTime(Date bulidTime) {
        this.bulidTime.setText(bulidTime.toString());
         
    }

    /**
     * @return the localFilename
     */
    public String getLocalFilename() {
        return localFilename.getText();
    }

    /**
     * @param localFilename the localFilename to set
     */
    public void setLocalFilename(String localFilename) {
        this.localFilename.setText(localFilename);
    }

    /**
     * @return the remoteFilename
     */
    public String getRemoteFilename() {
        return remoteFilename.getText();
    }

    /**
     * @param remoteFilename the remoteFilename to set
     */
    public void setRemoteFilename(String remoteFilename) {
        this.remoteFilename.setText(remoteFilename);
    }

    /**
     * @return the sourceMailBox
     */
    public String getSourceMailBox() {
        return sourceMailBox.getText();
    }

    /**
     * @param sourceMailBox the sourceMailBox to set
     */
    public void setSourceMailBox(String sourceMailBox) {
        this.sourceMailBox.setText(sourceMailBox);
    }




    public void updateTask(jTask task)
    {
        setAimMailBox( task.getAimMailBox() );
        setBulidTime( task.getBuildTime() );
        setLocalFilename( task.getLocalFilename() );
        setRemoteFilename( task.getRemoteFilename() );
        setSourceMailBox( task.getSourceMailBox() );

    }

    
}
